package com.easyaccount.controller;

import com.easyaccount.commons.CommonResp;
import com.easyaccount.commons.TablePage;
import com.easyaccount.model.DailyAcctDict;
import com.easyaccount.service.DailyAcctDictService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/dailyAcctDict")
public class DailyAcctDictController {

    @Resource
    private DailyAcctDictService dailyAcctDictService;

    @RequestMapping("all")
    public CommonResp all(){
        return dailyAcctDictService.list();
    }

    @RequestMapping("list")
    public TablePage list(TablePage tablePage){
        return dailyAcctDictService.searchByName(tablePage, null);
    }

    @RequestMapping("add")
    public CommonResp list(DailyAcctDict dailyAcctDict){
        return dailyAcctDictService.save(dailyAcctDict);
    }

    @RequestMapping("update")
    public CommonResp update(DailyAcctDict dailyAcctDict){
        return dailyAcctDictService.update(dailyAcctDict);
    }

    @RequestMapping("delete")
    public CommonResp delete(DailyAcctDict dailyAcctDict){
        return dailyAcctDictService.delete(dailyAcctDict);
    }

    @RequestMapping("search")
    public TablePage search(TablePage tablePage,@RequestParam("name") String name){
        TablePage result = dailyAcctDictService.searchByName(tablePage, name);
        return result;
    }

}
